import 'dart:ui';

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              children: [
                Container(
                  width: 120,
                  height: 100,
                  child: Text("这是sRGB红"),
                  color: Color.from(
                      alpha: 1.0,
                      red: 1.0,
                      green: 0.0,
                      blue: 0.0,
                      colorSpace: ColorSpace.sRGB),
                ),
                Container(
                  width: 120,
                  height: 100,
                  child: Text("这是sRGB绿"),
                  color: Color.from(
                      alpha: 1.0,
                      red: 0.0,
                      green: 1.0,
                      blue: 0.0,
                      colorSpace: ColorSpace.sRGB),
                ),
                Container(
                  width: 120,
                  height: 100,
                  child: Text("这是sRGB蓝"),
                  color: Color.from(
                      alpha: 1.0,
                      red: 0.0,
                      green: 0.0,
                      blue: 1.0,
                      colorSpace: ColorSpace.sRGB),
                ),
              ],
            ),
            Row(
              children: [
                Container(
                  width: 120,
                  height: 100,
                  child: Text("这是displayP3红"),
                  color: Color.from(
                      alpha: 1.0,
                      red: 1.0,
                      green: 0.0,
                      blue: 0.0,
                      colorSpace: ColorSpace.displayP3),
                ),
                Container(
                  width: 120,
                  height: 100,
                  child: Text("这是displayP3绿"),
                  color: Color.from(
                      alpha: 1.0,
                      red: 0.0,
                      green: 1.0,
                      blue: 0.0,
                      colorSpace: ColorSpace.displayP3),
                ),
                Container(
                  width: 120,
                  height: 100,
                  child: Text("这是displayP3蓝"),
                  color: Color.from(
                      alpha: 1.0,
                      red: 0.0,
                      green: 0.0,
                      blue: 1.0,
                      colorSpace: ColorSpace.displayP3),
                ),
              ],
            ),
            Image.asset('images/srgb.jpg'),
            Image.asset('images/displayp3.jpg'),
            Image.asset('images/image_red_P3.jpg'),
          ],
        ),
      ),
    );
  }
}
